package io.vincentwinner.systeminfoapi;

import lombok.SneakyThrows;
import org.springframework.web.servlet.ModelAndView;

public class ContentDispatcher extends ModelAndView implements Cloneable{

    private static final class ContentDispatcherInstance{
        private static final ContentDispatcher instance = new ContentDispatcher();
    }

    private ContentDispatcher() {
        this.setViewName("index");
    }

    @SneakyThrows
    public static ContentDispatcher forward(String contentPage) {
        ContentDispatcher dispatcher = ContentDispatcherInstance.instance.clone();
        dispatcher.addObject("contentURL",contentPage);
        return dispatcher;
    }

    @Override
    protected ContentDispatcher clone() throws CloneNotSupportedException {
        return (ContentDispatcher) super.clone();
    }

}
